home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PRINTER / EPSON.ARJ / SIDEPRNT.PAS < prev    next >
Pascal/Delphi Source File  |  1986-10-01  |  5KB  |  181 lines

  1. {
  2.  SIDEPRNT ... sideways (rotated) printing ...
  3.  Author --- John T. Bagwell, Jr.
  4.  
  5. Uses Character tables in the BIOS ROM sto do a simple form of
  6. sideways printing. Character values above 127 aren't supported.
  7.  
  8. Formfeed acts as a 'page' eject, even in the middle of a line;
  9. a line ends at CR/LF, FF, or end-of-file.
  10.  
  11. This program is designed for the Epson FX-80 or FX-85 printer.
  12.  
  13. }
  14.  
  15.  
  16. program SidePrint;
  17.  
  18. const
  19.   PrintMultipleSpacing = #27'3';
  20.   JiggleDown = #13#27'J'#1;
  21.   NormalSpacing = #27'2';
  22.   GraphicsPrint = #27'*';
  23.   LineFeed = ^J;
  24.   FormFeed = ^L;
  25.                             { possible choices }
  26.   BitsPerChar =      9;   { 9  8  9  8  9  8  9  8 }
  27.   ModeCode =        #0;   {#0 #0 #4 #4 #5 #5 #6 #6 }
  28.   MaxLinesPerPage = 53;   {53 61 71 80 64 72 80 90 }
  29.   MaxLineLen =    1000;   {adjust to match max lines and available space}
  30.  
  31. type
  32.   BitMap = array[0..7] of Char;
  33.   Line = array[1..MaxLineLen] of Char;
  34.  
  35. var
  36.   Paper: array[1..MaxLinesPerPage] of Line;
  37.   InFile: Text;
  38.   InChar: Char;
  39.   LineNo,CharNo,i,j,k,BitsPerPage,LineLen: Integer;
  40.   Cindex,PrintMultiple: Byte;
  41.   CharTable: array[0..127] of BitMap absolute $F000:$FA6E;  {BIOS Table}
  42.  
  43. (*---------------------------------*)
  44. (*         READ ONE PAGE           *)
  45. (*---------------------------------*)
  46.  
  47. procedure ReadOnePage;
  48.  
  49. var
  50.   LineSize: array[1..91] of Integer;    {big enough for all options}
  51.   eject: Boolean;
  52.  
  53. begin
  54.   LineNo:=1;
  55.   CharNo:=0;
  56.   LineLen:=0;
  57.   eject:=False;
  58.  
  59.   For i:=1 to MaxLinesPerPage do     {erase old lines}
  60.     LineSize[i]:=0;
  61.  
  62. repeat
  63.         {accumulate a line ...}
  64.   While (not eoln(InFile)) AND (not eject) do
  65.     begin
  66.       Read(InFile,InChar);
  67.       If InChar=FormFeed then          {watch for page ejects}
  68.         If (LineNo=1) AND (CharNo=0) then
  69.             {Ignore redundant page ejects}
  70.         else
  71.           eject:=True
  72.       else
  73.         If CharNo <= MaxLineLen then       {build a line}
  74.           begin
  75.             CharNo:=CharNo+1;
  76.             Paper[LineNo,CharNo]:=InChar;
  77.           end;
  78.     end;
  79.  
  80.           {at end of each line ...}
  81.  
  82.     If CharNo > LineLen then             {save longest line length}
  83.       LineLen:=CharNo;
  84.     LineSize[LineNo]:=CharNo;
  85.     LineNo:=LineNo+1;
  86.     CharNo:=0;
  87.     If eoln(InFile) then
  88.       ReadLn(InFile);                    {get the end-of-line mark}
  89.  
  90.       {force eject when page is full ...}
  91.  
  92.     If LineNo > MaxLinesPerPage then
  93.       eject:=True;
  94.  
  95. until eof(InFile) OR (eject);
  96.  
  97. (*  make each line the same length *)
  98.  
  99. For i:=1 to MaxLinesPerPage do
  100.   For j:=LineSize[i]+1 to LineLen do
  101.     Paper[i,j]:=' ';
  102.  
  103. end;   {procedure ReadOnePage}
  104.  
  105. (*--------------------------------*)
  106. (*        PRINT ONE PAGE          *)
  107. (*--------------------------------*)
  108.  
  109. procedure PrintOnePage;
  110.  
  111. begin
  112.   For j:=1 to LineLen do   {each rotated 'line'... actually, each character}
  113.     begin
  114.       For LineNo:=1 to PrintMultiple do
  115.         begin
  116.           Write(Lst,GraphicsPrint,ModeCode,
  117.             Char(Lo(BitsPerPage)),Char(Hi(BitsPerPage)));
  118.           For i:=MaxLinesPerPage downto 1 do    {lines in reverse order}
  119.             begin
  120.               Cindex:=Ord(Paper[i,j]);
  121.               If BitsPerChar = 9 then {For loop (9 to ...) req'd if it is >9}
  122.                 Write(Lst,#0);
  123.               For k:=7 downto 0 do
  124.                 Write(Lst,CharTable[Cindex][k]);   {bottom up each char}
  125.             end;
  126.           Write(Lst,JiggleDown);      {C/R + microspace down}
  127.         end;
  128.       Write(Lst,LineFeed);            {next 'line'}
  129.     end;
  130. end;    {procedure PrintOnePage}
  131.  
  132.  
  133. (* -------- MAIN PROGRAM -------- *)
  134.  
  135.  
  136. begin
  137.  
  138.     (*  GET FILE PARAMETERS *)
  139.  
  140.   If Paramcount < 1 then
  141.     begin
  142.       WriteLn(^G'Missing file name on command line');
  143.       Halt;
  144.     end;
  145.   Assign(InFile,Paramstr(1));     {OPEN the file}
  146.   {$I-}
  147.   Reset(InFile);
  148.   {$I+}
  149.   If IOResult <> 0 then
  150.     begin
  151.       WriteLn('File "',Paramstr(1),'" not found.');
  152.       Halt;
  153.     end;
  154.  
  155.     (*  GET /D DOUBLE-PRINT OPTION  *)
  156.  
  157.   PrintMultiple:=1;
  158.   If Paramcount >= 2 then
  159.     If (Paramstr(2) = '/d') OR (paramstr(2) = '/D') then
  160.       PrintMultiple:=2;
  161.  
  162.     (*  SET UP *)
  163.  
  164.   BitsPerPage:=BitsPerChar * MaxLinesPerPage;
  165.   Write(Lst,PrintMultipleSpacing,Char(24-PrintMultiple));   {nn/216th inch}
  166.  
  167.     (*  MAIN LOOP  *)
  168.  
  169.   Repeat       {do one "page" at a time}
  170.     ReadOnePage;
  171.     PrintOnePage;
  172.     Write(Lst,FormFeed);      {do a page eject to line up properly}
  173.   until eof(InFile);
  174.  
  175.     (*  ALL DONE  *)
  176.  
  177.   Close(InFile);
  178.   Write(Lst,NormalSpacing);        {resume normal spacing vertically}
  179. end.   {main program}
  180.  
  181.